import { TipsItem } from "../view/msgtips/TipsItem";
import { ObjectPool } from "../../../com/gengine/utils/pools/ObjectPool";
import { Global } from "../../../com/gengine/global/Global";
type int = number;
//class MsgTipTextImpl
    
    export  class MsgTipTextImpl /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._items = [];
            mouseEnabled = false;
            mouseChildren = false;
            this.scrollRect = new Object /* flash.geom.Rectangle */(0, 0, this.width, this.height);
            return;
        }

        /* internal  */onItemHide(arg1: TipsItem): void
        {
            return;
        }

        public showInfo(arg1: string, arg2: string="#ffff00", arg3: int=0): void
        {
            var loc3=null;
            var loc5=null;
            var loc1=0;
            var loc2;
            if ((loc2 = this._items.length) >= this.maxLen) 
            {
                (loc3 = this._items.pop()).dispose();
                ObjectPool.disposeObject(loc3, TipsItem);
                removeChild(loc3);
            }
            (loc3 = ObjectPool.getObject(TipsItem)).updateData(arg1, arg2, arg3, this.onItemHide);
            loc1 = 0;
            loc2 = this._items.length;
            var loc4=false;
            while (loc1 < loc2) 
            {
                if (!(loc5 = this._items[loc1]).hideAble) 
                {
                    this._items.splice(loc1, 0, loc3);
                    loc4 = true;
                    break;
                }
                ++loc1;
            }
            if (loc4 == false) 
            {
                this._items.push(loc3);
            }
            addChild(loc3);
            this.updatePy();
            return;
        }

        /* internal  */updatePy(): void
        {
            var loc1=0;
            var loc3=0;
            var loc4=null;
            var loc2=this._items.length;
            while (loc1 < loc2) 
            {
                (loc4 = this._items[loc1]).y = this.height - 2 - loc3 - loc4.height;
                if (!(loc1 == 0) && !loc4.colorUpdated) 
                {
                    loc4.updateColor();
                }
                loc4.easeIn();
                loc3 = loc3 + loc4.height;
                ++loc1;
            }
            return;
        }

        public stageResize(): void
        {
            x = Global.stage.stageWidth - this.width - 60;
            y = Global.stage.stageHeight - this.height - 130;
            return;
        }

        public /* override */ get height(): number
        {
            return 30;
        }

        public /* override */ get width(): number
        {
            return 150;
        }

        /* internal */ /* const */maxLen: int=3;

        /* internal */ /* var */_items: Array<any>;
    }
